package com.ease.web.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

/**
 * 
 * @author nathanleewei
 * 
 */
public class AttainableSuffixFilter implements Filter {

	public void init(FilterConfig config) throws ServletException {

	}

	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) req;
		// HttpServletResponse response = (HttpServletResponse) res;
		String requestUrl = request.getRequestURL().toString();
		if (null != requestUrl && requestUrl.indexOf('.') > 0) {
			requestUrl = requestUrl.substring(requestUrl.lastIndexOf('.') + 1);
		}
		throw new RuntimeException("invalid request suffix:" + requestUrl);
	}

	public void destroy() {

	}
}
